package com.cmbchina.designpattern.application.house.material;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.Getter;

@Data
@AllArgsConstructor
public abstract class Material {
    /**
     * 材料名称
     */
    private String name;

    /**
     * 材料强度
     */
    private int strength;

    /**
     * 材料数量
     */
    private int amount;

    /**
     * 数量单位
     */
    private Unit unit;

    /**
     * @return 总体材料的强度
     */
    public int overallStrength() {
        return amount * strength * unit.getStrength();
    }

    @Override
    public String toString() {
        return name + " strength-" + strength + "(" + getAmount() + " " + getUnit() + ")";
    }

    /**
     * 材料单位
     */
    public enum Unit {

        /**
         * 千克
         */
        KILOGRAM(1),

        /**
         * 吨
         */
        TON(1000);

        @Getter
        private final int strength;

        Unit(int strength) {
            this.strength = strength;
        }
    }

}
